The present invention relates generally to texture mapping of three-dimensional computer graphics, and more particularly to an apparatus and method for texture mapping using multiple levels of detail.
An object image of full resolution can be pre-filtered and represented by a number of primitive objects or simple textures with lower resolution. The simple textures can then be drawn according to its geometric coordinates. The process of converting a high resolution object image into low resolution simple textures is called mipmapping. Mipmapping technique has been used in texture mapping for three dimensional computer graphics. A texture can be described as a single pixel, an element, two elements, three elements or four elements.
Mipmapping technique selects proper textures for describing a primitive object based on functions of multiple levels of detail. The textures are processed in order to accurately describe the primitive object. FIG. 1 illustrates the process of a conventional mipmapping technique for texture mapping of a primitive object. The primitive object a 101 which is a triangle in FIG. 1 is shown in a X-Y coordinate system. The texture 102 is shown in a S-T coordinate system. The texture mapping 103 is drawn after mipmapping according to a function of multiple levels of detail.
For each pixel at (X, Y) in the X-Y coordinate system with corresponding texture coordinate (S, T) in the S-T coordinate system, the multiple levels of detail (LOD) is defined in Eq. (1):                     d        =                  LOD          =                                    log              2                        ⁡                          (                              max                ⁡                                  (                                                                                                                                          (                                                                                          ∂                                S                                                                                            ∂                                X                                                                                      )                                                    2                                                +                                                                              (                                                                                          ∂                                T                                                                                            ∂                                X                                                                                      )                                                    2                                                                                      ,                                                                                                                        (                                                                                          ∂                                S                                                                                            ∂                                Y                                                                                      )                                                    2                                                +                                                                              (                                                                                          ∂                                T                                                                                            ∂                                Y                                                                                      )                                                    2                                                                                                      )                                            )                                                          (        1        )            
where ∂S/∂X is the partial differential of S with respect to X, ∂T/∂X is the partial differential of T with respect to X, ∂S/∂Y is the partial differential of S with respect to Y, and ∂T/∂Y is the partial differential of T with respect to Y.
Because it is difficult to realize the above multiple levels of detail shown in Eq. (1) with hardware for each pixel, conventional mipmapping technique usually uses modified approach to compute the multiple levels of detail. For example, in three dimensional computer graphics software or chips, certain values for constant levels of detail for a primitive object are found first. Interpolation technique is then used to fill in more values and improves the resolution. During the interpolation, perspective correction may or may not be applied.
FIG. 2 shows pre-filtered images generated in the texture mapping of a primitive object using mipmapping technique. The values d for the multiple levels of detail shown in the figure are 0, 1, 2, . . . , etc. The size of the pre-filtered image is identical to that of the original texture when d is equal 0. If the value d is 1, the size of the pre-filtered image is reduced to xc2xc. If the value d is 2, the size is reduced to {fraction (1/16)}. If the value is 3, the size is reduced to {fraction (1/64)}, and so on.
The conventional mipmapping technique has drawback as well as difficulty in its implementation. The difficulty is that the conventional technique requires the use of a monotonically increasing function f(x,y) which has continuous |∂S/∂X, |∂T/∂X|, |∂S/∂Y| and |∂T/∂Y| to find the approximate value of Eq. (1). And, in fact, it is not easy to realize the function f(x,y). The drawback is poor quality in the resulted texture mapping. The effect of simulating the real object is not good either.
The present invention has been made to overcome the above mentioned drawback and difficulty in the texture mapping of three dimensional computer graphics. The primary object of the invention is to provide a method and apparatus for a texture mapping technique using multiple levels of detail. According to the invention, appropriate texture mapping is selected according to the viewing distance from the original object.
Another object of the invention is to provide a method and apparatus for texture mapping in which each pixel can be realized with hardware according to a special equation disclosed in the present invention. The primitive object is represented by a triangle. By using available and useful data of the three vertices of a triangle and the equation that represents the plane of the triangle, the standard formula Eq. (1) describing multiple levels of detail is converted into an equivalent formula. The texture mapping using the equivalent formula can be easily implemented by hardware.
A further object of the invention is to provide a method and apparatus for texture mapping that can result in high accuracy and optimal simulation effect of the original object. According to a preferred embodiment of the present invention, the computation of a log2(x) function that is required in computing the equivalent formula of this invention is achieved by using a log2 look-up table. The first three bits of the mantissa of a value x are used as the index to the log2 look-up table in order to find the fractional part of the logarithmic value which has 10 binary bits precision.
The foregoing and other objects, features, aspects and advantages of the present invention will become more apparent from a careful reading of a detailed description provided herein below, with appropriate reference to the accompanying drawings.